package com.qdaily.ui.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.qdaily.ui.MainActivity;
import com.qdaily.ui.QDBaseActivity;
import com.qdaily.ui.R;
import com.qdaily.ui.data.QDConfigConstants;

/**
 * 启动页，主要区分是启动whatsnew还是主页
 * Created with IntelliJ IDEA.
 * User: Felix
 * Date: 5/14/15
 * Time: 16:53
 * QQ:74104
 * Email:lovejiuwei@gmail.com
 */
public class LauncherActivity extends QDBaseActivity {

    private final int delayTime = 2 * 1000;

    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Intent intent = new Intent();
            if (getQDConfigManager().getBoolean(QDConfigConstants.KEY_IF_FIRST_ENTER, true)) {
                intent.setClass(LauncherActivity.this, WhatsNewActivity.class);
            } else {
                intent.setClass(LauncherActivity.this, MainActivity.class);
            }
            startActivity(intent);
            LauncherActivity.this.finish();
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);

        handler.sendEmptyMessageDelayed(0, delayTime);
    }

}
